package com.xiaoshuidi.cloud.module.iot.enums;

import java.util.Arrays;
import java.util.Optional;
import java.util.stream.Stream;

/**
 * @author arvin
 * @date 2019-05-28 10:59
 * @description 设备类型
 */

public enum DeviceTypeEnum {
    COLD_WATERMETE_TYPE_ENUM("cold_watermeter", "冷水表", "water", "2", "10000002", "WaterMeter", "", "0"),
    HOT_WATERMETE_TYPE_ENUM("hot_watermeter", "热水表", "hotwater", "", "", "", "", "1"),
    AMMETER("ammeter", "电表", "elec", "1", "10000003", "SmartElectricityMeter", "", "64"),
    DOORLOCK("doorlock", "门锁", "locker", "", "10000001", "SmartDoor", "", ""),
    SMOKESENSOR("smokesensor", "烟感", "", "", "", "", "", ""),
    PASS("pass", "人脸门禁机", "", "", "", "", "SPS", ""),
    SENSE("sense", "人证核验一体机", "", "", "", "", "SID", "");


    private String code;
    private String msg;
    private String qiandingDevcieCode;
    private String biteDeviceCode;
    /**
     * 10000002:水表（包含热水表，冷水表）
     */
    private String antDeviceCode;
    private String aliHomeLinkCode;
    private String shangtangCode;
    private String fengdianCode;

    DeviceTypeEnum(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    DeviceTypeEnum(String code, String msg, String qiandingDevcieCode) {
        this.code = code;
        this.msg = msg;
        this.qiandingDevcieCode = qiandingDevcieCode;
    }

    DeviceTypeEnum(String code, String msg, String qiandingDevcieCode, String biteDeviceCode) {
        this.code = code;
        this.msg = msg;
        this.qiandingDevcieCode = qiandingDevcieCode;
        this.biteDeviceCode = biteDeviceCode;
    }

    DeviceTypeEnum(String code, String msg, String qiandingDevcieCode, String biteDeviceCode, String antDeviceCode) {
        this.code = code;
        this.msg = msg;
        this.qiandingDevcieCode = qiandingDevcieCode;
        this.biteDeviceCode = biteDeviceCode;
        this.antDeviceCode = antDeviceCode;
    }

    DeviceTypeEnum(String code, String msg, String qiandingDevcieCode, String biteDeviceCode, String antDeviceCode, String aliHomeLinkCode) {
        this.code = code;
        this.msg = msg;
        this.qiandingDevcieCode = qiandingDevcieCode;
        this.biteDeviceCode = biteDeviceCode;
        this.antDeviceCode = antDeviceCode;
        this.aliHomeLinkCode = aliHomeLinkCode;
    }

    DeviceTypeEnum(String code, String msg, String qiandingDevcieCode, String biteDeviceCode, String antDeviceCode, String aliHomeLinkCode, String shangtangCode) {
        this.code = code;
        this.msg = msg;
        this.qiandingDevcieCode = qiandingDevcieCode;
        this.biteDeviceCode = biteDeviceCode;
        this.antDeviceCode = antDeviceCode;
        this.aliHomeLinkCode = aliHomeLinkCode;
        this.shangtangCode = shangtangCode;
    }

    DeviceTypeEnum(String code, String msg, String qiandingDevcieCode, String biteDeviceCode, String antDeviceCode, String aliHomeLinkCode, String shangtangCode, String fengdianCode) {
        this.code = code;
        this.msg = msg;
        this.qiandingDevcieCode = qiandingDevcieCode;
        this.biteDeviceCode = biteDeviceCode;
        this.antDeviceCode = antDeviceCode;
        this.aliHomeLinkCode = aliHomeLinkCode;
        this.shangtangCode = shangtangCode;
        this.fengdianCode = fengdianCode;
    }

    public String getFengdianCode() {
        return fengdianCode;
    }

    public void setFengdianCode(String fengdianCode) {
        this.fengdianCode = fengdianCode;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getQiandingDevcieCode() {
        return qiandingDevcieCode;
    }

    public void setQiandingDevcieCode(String qiandingDevcieCode) {
        this.qiandingDevcieCode = qiandingDevcieCode;
    }

    public String getBiteDeviceCode() {
        return biteDeviceCode;
    }

    public void setBiteDeviceCode(String biteDeviceCode) {
        this.biteDeviceCode = biteDeviceCode;
    }

    public static DeviceTypeEnum getDeviceTypeEnumByCode(String code) {
        return Arrays.stream(DeviceTypeEnum.values()).filter(deviceTypeEnum -> code.equals(deviceTypeEnum.getCode())).findFirst().get();
    }

    public String getAntDeviceCode() {
        return antDeviceCode;
    }

    public void setAntDeviceCode(String antDeviceCode) {
        this.antDeviceCode = antDeviceCode;
    }

    public String getAliHomeLinkCode() {
        return aliHomeLinkCode;
    }

    public void setAliHomeLinkCode(String aliHomeLinkCode) {
        this.aliHomeLinkCode = aliHomeLinkCode;
    }

    public String getShangtangCode() {
        return shangtangCode;
    }

    public void setShangtangCode(String shangtangCode) {
        this.shangtangCode = shangtangCode;
    }

    /**
     * 根据千丁type查询水滴type
     *
     * @param qiandingDevcieCode
     * @return
     */
    public static DeviceTypeEnum getDeviceTypeEnumByQianDingCode(String qiandingDevcieCode) {
        Optional<Stream<DeviceTypeEnum>> deviceTypeEnumStream = Optional.ofNullable(Arrays.stream(DeviceTypeEnum.values()).filter(deviceTypeEnum -> qiandingDevcieCode.equals(deviceTypeEnum.getQiandingDevcieCode())));
        if (deviceTypeEnumStream.isPresent()) {
            return deviceTypeEnumStream.get().findFirst().get();
        }
        return null;
    }

    /**
     * 根据比特type查询水滴type
     *
     * @param biteDeviceCode
     * @return
     */
    public static DeviceTypeEnum getDeviceTypeEnumByBiteCode(String biteDeviceCode) {
        Optional<Stream<DeviceTypeEnum>> deviceTypeEnumStream = Optional.ofNullable(Arrays.stream(DeviceTypeEnum.values()).filter(deviceTypeEnum -> biteDeviceCode.equals(deviceTypeEnum.getBiteDeviceCode())));
        if (deviceTypeEnumStream.isPresent()) {
            return deviceTypeEnumStream.get().findFirst().get();
        }
        return null;
    }

    /**
     * 根据蚂蚁type查询水滴type
     *
     * @param antDeviceCode
     * @return
     */
    public static DeviceTypeEnum getDeviceTypeEnumByAntCode(String antDeviceCode) {
        Optional<Stream<DeviceTypeEnum>> deviceTypeEnumStream = Optional.ofNullable(Arrays.stream(DeviceTypeEnum.values()).filter(deviceTypeEnum -> antDeviceCode.equals(deviceTypeEnum.getAntDeviceCode())));
        if (deviceTypeEnumStream.isPresent()) {
            return deviceTypeEnumStream.get().findFirst().get();
        }
        return null;
    }

    /**
     * 根据阿里智慧人居type查询水滴type
     *
     * @param aliHomeLinkCode
     * @return
     */
    public static DeviceTypeEnum getDeviceTypeEnumByAliHomeLinkCode(String aliHomeLinkCode) {
        Optional<Stream<DeviceTypeEnum>> deviceTypeEnumStream = Optional.ofNullable(Arrays.stream(DeviceTypeEnum.values()).filter(deviceTypeEnum -> aliHomeLinkCode.equals(deviceTypeEnum.getAliHomeLinkCode())));
        if (deviceTypeEnumStream.isPresent()) {
            return deviceTypeEnumStream.get().findFirst().get();
        }
        return null;
    }

    /**
     * 根据商汤type查询水滴type
     *
     * @param shangtangCode
     * @return
     */
    public static DeviceTypeEnum getDeviceTypeEnumByShangTangCode(String shangtangCode) {
        Optional<Stream<DeviceTypeEnum>> deviceTypeEnumStream = Optional.ofNullable(Arrays.stream(DeviceTypeEnum.values()).filter(deviceTypeEnum -> shangtangCode.equals(deviceTypeEnum.getShangtangCode())));
        if (deviceTypeEnumStream.isPresent()) {
            return deviceTypeEnumStream.get().findFirst().get();
        }
        return null;
    }

    /**
     * 根据蜂电type查询水滴type
     *
     * @param fengdianCode
     * @return
     */
    public static DeviceTypeEnum getDeviceTypeEnumByFengDianCode(String fengdianCode) {
        Optional<Stream<DeviceTypeEnum>> deviceTypeEnumStream = Optional.ofNullable(Arrays.stream(DeviceTypeEnum.values()).filter(deviceTypeEnum -> fengdianCode.equals(deviceTypeEnum.getFengdianCode())));
        if (deviceTypeEnumStream.isPresent()) {
            return deviceTypeEnumStream.get().findFirst().get();
        }
        return null;
    }
}
